package org.teamh.gui.engine.model;

import org.lwjgl.opengl.GL11;

/**
 * This class represents a single mesh of an object. 
 * @author richard
 *
 */
public abstract class Mesh {
	private int[] buffers;
	private int numVertices;
	
	private int texture;
	private Material material;

	public Mesh(int[] buffers, int numVertices) {
		this.buffers = buffers;
		this.numVertices = numVertices;
	}
	
	public void setTexture(int texture) {
		this.texture = texture;
	}
	
	public int getTexture() {
		return texture;
	}
	
	public void setMaterial(Material material) {
		this.material = material;
	}
	
	public int[] getBuffers() {
		return buffers;
	}
	
	public int getNumVertices() {
		return numVertices;
	}
	
	public Material getMaterial() {
		return material;
	}
	
	public abstract void render() ;
	
	/**
	 * Removes all the vbo lists from the graphics card storage. 
	 */
	public void dealloc() {
		for(int i = 0; i < buffers.length; i++) {
			VBO.glDeleteBuffer(buffers[i]);
		}
		
		GL11.glDeleteTextures(texture);
	}
}
